-
Notifications
You must be signed in to change notification settings - Fork 166
Add error handling for plan&execute agent #3845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Hailong Cui <ihailong@amazon.com>
Thanks for the fixes @Hailong-am ! Let me know when it is ready for review. Can you also please create an issue for the fixes involved in this PR? Thanks! |
Signed-off-by: Hailong Cui <ihailong@amazon.com>
@pyek-bot PR description updated with issue number and the what's the actual fix, please help to take a look |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3845 +/- ##
============================================
+ Coverage 80.26% 80.28% +0.02%
- Complexity 7815 7820 +5
============================================
Files 683 683
Lines 34513 34519 +6
Branches 3839 3840 +1
============================================
+ Hits 27702 27714 +12
+ Misses 5107 5099 -8
- Partials 1704 1706 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes! Looks good!
@@ -528,6 +528,11 @@ String extractJsonFromMarkdown(String response) { | |||
if (response.contains("```")) { | |||
response = response.substring(0, response.lastIndexOf("```")); | |||
} | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This method doesn't have any null check for
response
- Is there any chance that multiple code block can exist?
- what about json array?
- what happens if there's any string literals like
{"data": "{nested}"}
- Possible IndexOutOfBoundsException if markers aren't found
- why do we need second trim?
- Using substring multiple times creates multiple intermediate string objects
Each operation like contains(), indexOf(), and lastIndexOf() scans through the string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method doesn't have any null check for response
response
passed to this method could not be null, otherwise it will throw NPE before call it. But it's a good practice to add null check here
Is there any chance that multiple code block can exist?
what about json array?
what happens if there's any string literals like {"data": "{nested}"}
Yes, all of them are possible. the logic here is try our best to extract the expected json from LLM response.
Possible IndexOutOfBoundsException if markers aren't found
if markers are not found, it will not perform substring
why do we need second trim?
the content extracted from json
block may have spaces, so trim is needed here before check it's a valid json string.
Using substring multiple times creates multiple intermediate string objects
Each operation like contains(), indexOf(), and lastIndexOf() scans through the string
that's not a big concern. the response is not large, and gc will help to handle intermediate string objects
Signed-off-by: Hailong Cui <ihailong@amazon.com>
@Hailong-am fix spotless please, |
Signed-off-by: Hailong Cui <ihailong@amazon.com>
@dhrubo-os @ylwu-amzn I have applied the spotless, can you review it again. |
Signed-off-by: Hailong Cui <ihailong@amazon.com>
Description
Related Issues
#3848
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.